<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
    <title>付款</title>
    <script src="js/jquery-1.10.2.js"></script>
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .contain {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            margin-top: 100px;
        }

        .cash {
            width: 190px;
            outline: none;
            border: 0;
            border-radius: 0;
            border-bottom: .5px solid #FC8A02;
            margin: 30px 5px 30px 0;
            text-align: center;
            font-size: 50px;
        }

        button {
            color: #fff;
            background: #FC8A02;
            width: 80%;
            border: 0;
            border-radius: 999px;
            text-align: center;
            outline: none;
            margin: 40px auto;
            height: 45px;
            font-size: 20px;
            letter-spacing: 1px;
        }
    </style>
</head>

<body>
    <div class="contain">
        <h3 style="color: #FC8A02;">根据您预留信息, 本订单需支付</h3>
        <div style="margin: 30px auto;">
            <input type="text" class="cash" readonly="true"><span>元</span>
        </div>
        <h5>请按您所选择时间, 去指定地点准时换电</h5>
        <button class="confirm">确认付款</button>
    </div>
</body>
<script>
    $(() => {
        let param = window.location.search.split('=')[1]
        console.log(param)

        $.ajax({
            type: 'POST',
            url: 'https://api.cd1a.cn/index.php/activity/Swapnew/getMoney',
            data: {
                order_id: param
            }
        }).then(res => {
            console.log(res)
            $('.cash').val(res.data.prcie)
        })

        $('.confirm').click(() => {
            let money = $('.cash').val()
            if (isWeiXin()) {
                // 判断小程序的环境
                if (window.__wxjs_environment === 'miniprogram') {
                    wx.miniProgram.navigateTo({
                        url: `/pages/discount/discount?fee=${money} + &orderId=${param}`
                    })
                }
            }
        })

        //判断微信
        function isWeiXin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true; // 是微信端
            } else {
                return false;
            }
        }
    })
</script>

</html>